﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.Infra.UI.Common;

namespace Sinacor.UI.Bovespa.Movimento.Communication.Translator.DataContractToModel
{
    public class ConsultaAssessor
    {
        public ModelCollection<Model.Agente> ToAgente(List<Bovespa.Movimento.ConsultaAssessor.AgenteResponse> from)
        {
            ModelCollection<Model.Agente> to = null;

            if (from != null)
            {
                to = new ModelCollection<Model.Agente>();

                foreach (Bovespa.Movimento.ConsultaAssessor.AgenteResponse item in from)
                {
                    to.Add(ToAgente(item));
                }
            }

            return to;
        }

        private Model.Agente ToAgente(Bovespa.Movimento.ConsultaAssessor.AgenteResponse from)
        {
            Model.Agente to = null;

            if (from != null)
            {
                to = new Model.Agente();

                to.Codigo = from.Codigo;
                to.CodigoAssessor = from.CodigoAssessor;
                to.Nome = from.Nome;
            }

            return to;
        }

        public ModelCollection<Model.Assessor> ToAssessor(List<Bovespa.Movimento.ConsultaAssessor.AssessorResponse> from)
        {
            ModelCollection<Model.Assessor> to = null;

            if (from != null)
            {
                to = new ModelCollection<Model.Assessor>();

                foreach (Bovespa.Movimento.ConsultaAssessor.AssessorResponse item in from)
                {
                    to.Add(ToAssessor(item));
                }
            }

            return to;
        }

        private Model.Assessor ToAssessor(Bovespa.Movimento.ConsultaAssessor.AssessorResponse from)
        {
            Model.Assessor to = null;

            if (from != null)
            {
                to = new Model.Assessor();

                to.Codigo = from.Codigo;
                to.Nome = from.Nome;
            }

            return to;
        }

        public ModelCollection<Model.Correspondente> ToCorrespondente(List<Bovespa.Movimento.ConsultaAssessor.CorrespondenteResponse> from)
        {
            ModelCollection<Model.Correspondente> to = null;

            if (from != null)
            {
                to = new ModelCollection<Model.Correspondente>();

                foreach (Bovespa.Movimento.ConsultaAssessor.CorrespondenteResponse item in from)
                {
                    to.Add(ToCorrespondente(item));
                }
            }

            return to;
        }

        private Model.Correspondente ToCorrespondente(Bovespa.Movimento.ConsultaAssessor.CorrespondenteResponse from)
        {
            Model.Correspondente to = null;

            if (from != null)
            {
                to = new Model.Correspondente();

                to.Codigo = from.Codigo;
                to.Nome = from.Nome;
            }

            return to;
        }

        public ModelCollection<Model.ConsultaAssessor> ToConsultaAssessor(List<Bovespa.Movimento.ConsultaAssessor.ConsultaAssessorResponse> from)
        {
            ModelCollection<Model.ConsultaAssessor> to = null;

            if (from != null)
            {
                to = new ModelCollection<Model.ConsultaAssessor>();

                foreach (Bovespa.Movimento.ConsultaAssessor.ConsultaAssessorResponse item in from)
                {
                    to.Add(ToConsultaAssessor(item));
                }
            }

            return to;
        }

        private Model.ConsultaAssessor ToConsultaAssessor(Bovespa.Movimento.ConsultaAssessor.ConsultaAssessorResponse from)
        {
            Model.ConsultaAssessor to = null;

            if (from != null)
            {
                to = new Model.ConsultaAssessor();

                to.CodigoAgente = from.CodigoAgente;
                to.CodigoAssessor = from.CodigoAssessor;
                to.CodigoCliente = from.CodigoCliente;
                to.CodigoCorrespondente = from.CodigoCorrespondente;
                to.ComissaoAgente = from.ComissaoAgente;
                to.ComissaoAssessor = from.ComissaoAssessor;
                to.CorretagemTotal = from.CorretagemTotal;
                to.DataMovimento = from.DataMovimento;
                to.Desconto = from.Desconto;
                to.TotalNegociacao = from.TotalNegociacao;
                to.ValorCorrespondente = from.ValorCorrespondente;
            }

            return to;
        }
    }
}
